package lab4;

import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;


public class EBankAccount {
    private String account;
    private String password;
    private RSAPrivateKey rsaPrivateKey;//注册时的密钥
    private RSAPublicKey rsaPublicKey;

    private RSAPublicKey clientRSAPublicKey;

    private int balance;

    EBankAccount(String account, String password, RSAPublicKey clientRSAPublicKey){
        this.account = account;
        this.password = password;
        this.clientRSAPublicKey = clientRSAPublicKey;
        balance = 0;
    }

    public String getAccount(){
        return account;
    }

    public String getPassword() {
        return password;
    }

    public RSAPublicKey getClientRSAPublicKey(){return clientRSAPublicKey;}


    public void setRsaKey(RSAPublicKey rsaPublicKey, RSAPrivateKey rsaPrivateKey){
        this.rsaPublicKey = rsaPublicKey;
        this.rsaPrivateKey = rsaPrivateKey;
    }

    public RSAPublicKey getRsaPublicKey(){
        return rsaPublicKey;
    }

    public RSAPrivateKey getRsaPrivateKey(){
        return rsaPrivateKey;
    }

    //取款
    public void withdraw(int money){
        if (money > balance){
            System.out.println("余额不足");
        }else{
            balance -= money;
            System.out.println("已扣款"+money+"元，余额还剩"+balance+"元");
        }
    }

    //存款
    public void deposit(int money){
        balance += money;
        System.out.println("已存款"+money+"元，余额还剩"+balance+"元");
    }
}
